package com.atguigu.gmall.product.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.BaseCategoryService;
import com.atguigu.gmall.product.vo.CategoryTreeVo;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author tangsy
 * @Description TODO
 * @date 2022/12/3 16:25
 * @Version 1.0
 */
@RequestMapping("/api/inner/rpc/product")
@RestController
public class CategoryRpcController {

    @Autowired
    BaseCategoryService baseCategoryService;

    @GetMapping("/category/tree")
    public Result<List<CategoryTreeVo>> getCategoryTree(){
        List<CategoryTreeVo> categoryTreeVoList = baseCategoryService.getCategoryTree();
        return Result.ok(categoryTreeVoList);
    }

    @GetMapping("/category/view/{c3Id}")
    public Result<CategoryTreeVo> getCategoryView(@PathVariable("c3Id")Long c3Id){
        CategoryTreeVo vo = baseCategoryService.getCategoryTreeWithC3Id(c3Id);
        return Result.ok(vo);
    }

}
